<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>模拟hash路由功能</title>
</head>
<body>
<ul>
	<li><a href="#/aaa">AAA</a></li>
	<li><a href="#/bbb">BBB</a></li>
	<li><a href="#/ccc">CCC</a></li>
</ul>
<div id="container"></div>
<script type="text/javascript">
let dom = document.getElementById('container');

window.onhashchange = function () {
	let hash = location.hash;
	console.log(location);
	console.log(hash);
	hash = hash.replace('#', '');
	switch (hash) {
		case '/aaa':
			dom.innerHTML = "AAAAAA"
			break;
		case '/bbb':
			dom.innerHTML = "BBBBBB"
			break;
		case '/ccc':
			dom.innerHTML = "CCCCCC"
			break;
	}
}
window.onpopstate = function (e) {
	console.log('popstate');//{data1: '11',data2: '22'};
};
</script>
</body>
</html>